@extends('home.layout')
@section('content')
    <!-- ngView:  -->
    <div class="ng-scope" ng-view="" role="main">
        <div class="container clearfix ng-scope">
            <div location="" class="location" ng-style="{visibility: geohash ? '' : 'hidden'}" role="navigation">
                <span>当前位置:</span> <span class="location-current"><a href="#" class="inherit ng-binding"
                                                                     ng-href="/place/wx4spk2q4gx" ubt-click="401"
                                                                     ng-bind="place.name || place.address">{{ $address }}</a></span>
                <span class="location-change"
                      ng-class="{ 'location-hashistory': user.username &amp;&amp; userPlaces &amp;&amp; userPlaces.length > 0 }"><a
                            href="{{asset('')}}" ng-href="/home" ubt-click="400" hardjump="">[切换地址]</a><ul
                            class="dropbox location-dropbox" ubt-visit="398"><li class="arrow"></li>
                        <!-- ngRepeat: userPlace in userPlaces | filter:filterPlace | limitTo: 4 --><li
                                class="changelocation"><a href="{{asset('')}}home" ng-href="/home"
                                                          hardjump="">修改收货地址<span
                                        class="icon-location"></span></a></li></ul></span> <span
                        ng-transclude=""></span></div>
            <div search-input="" class="place-search" role="search"><a ubt-data-keyword=""
                                                                       class="place-search-btn icon-search"
                                                                       ubt-click="403"
                                                                       title="搜索商家或美食"></a><label
                        for="globalsearch">搜索商家或美食</label><input id="globalsearch"
                                                                 class="place-search-input ng-pristine ng-valid"
                                                                 ng-model="searchText" autocomplete=""
                                                                 placeholder="搜索商家,美食...">
                <div class="searchbox">
                    <div class="searchbox-list searchbox-rstlist ng-hide"
                         ng-show="searchRestaurants &amp;&amp; searchRestaurants.length > 0"
                         ng-class="{ 'show-separator': searchFoods &amp;&amp; searchFoods.length > 0 }">
                        <ul>
                            <!-- ngRepeat: restaurant in searchRestaurants | orderBy: [ '-is_opening', 'order_lead_time' ] | limitTo: 5 --></ul>
                    </div>
                    <div class="searchbox-list searchbox-foodlist ng-hide"
                         ng-show="searchFoods &amp;&amp; searchFoods.length > 0">
                        <ul><!-- ngRepeat: food in searchFoods  | limitTo: 5 --></ul>
                    </div>
                </div>
            </div>
        </div><!-- ngIf: activities -->
        <div class="place-ad container ng-scope" role="banner" ng-if="activities">
            <div carousel="" class="activity-carousel carousel-wrapper ng-isolate-scope">
                {{--TODO: 轮播图--}}
                <ul class="carousel-list" ng-transclude="scrolled"><!-- ngRepeat: activity in activities -->
                    @foreach($data as $scrolled)
                        <li slide="" ng-repeat="activity in activities" class="carousel-block ng-scope ng-isolate-scope"
                            ng-transclude=""><a
                                    class="ng-scope" rel="nofollow" ng-href="/activity/609" target="_blank"
                                    ng-click="activityClick($event)" ubt-click="694"><img
                                        src="{{asset('upload/scrolled_images').'/'.$scrolled->image}}"

                                        alt=""></a>
                        </li>
                        <!-- end ngRepeat: activity in activities -->

                    <p style="display: none">{{$index = 1}}</p>
                    @endforeach
                </ul>
                <ol class="carousel-pager"><!-- ngRepeat: slide in slides -->
                    @foreach($data as $scrolled)
                    <li class="page-number ng-binding ng-scope" ng-repeat="slide in slides"
                        ng-class="scrolled_pos" ng-click="setActiveSlide({{$index}})"
                        style="background-color: #abcdef">{{$index++}}
                    </li><!-- end ngRepeat: slide in slides -->
                    @endforeach
                </ol>
            </div>
        </div><!-- end ngIf: activities -->
        <div class="place-tab clearfix container ng-scope">
            <div class="place-fetchtakeout ng-isolate-scope" show-fetch-takeout-dialog=""><img
                        src="{{asset('home/home/images/takeout.f58d1e.png')}}"

                        alt="谁去拿外卖"></div>
        </div>
        <div ng-show="!recentBoughtOnly" class="container ng-scope">
            <div class="excavator container"><!-- ngIf: rstCategories.length -->
                <div class="excavator-filter ng-scope" ng-if="rstCategories.length"><span class="excavator-filter-name">商家分类:</span>
                    <!-- //类别 -->
                    <!-- ngRepeat: category in rstCategories --><a  id = 'allbus'class="excavator-filter-item ng-binding ng-scope"
                                                                   href="javascript:"
                                                                   ng-repeat="category in rstCategories"
                                                                   ng-class="{'focus': clickedCategory === category.id &amp;&amp; (!clickedCategory || clickedCategory < 0) , 'active': activeCategory === category.id, 'premium': category.id === -10001 &amp;&amp; !pumStream}"
                                                                   ng-bind="category.name"
                                                                   ng-click="changeCategory(category)"
                                                                   ubt-click="380">全部商家</a>
                                                                  @foreach($cates as $cate)
                                                                    @if($cate -> status == 0)
                    <!-- end ngRepeat: category in rstCategories --><a id = 'firstType' class="excavator-filter-item ng-binding ng-scope"
                                                                       href="javascript:"
                                                                       ng-repeat="category in rstCategories"
                                                                       ng-class="{'focus': clickedCategory === category.id &amp;&amp; (!clickedCategory || clickedCategory < 0) , 'active': activeCategory === category.id, 'premium': category.id === -10001 &amp;&amp; !pumStream}"
                                                                       ng-bind="category.name"
                                                                       ng-click="changeCategory(category)"
                                                                       ubt-click="380" value = '{{ $cate -> id }}'>{{ $cate -> name }}</a>
                                                                    @endif
                                                                  @endforeach
                    <!-- end ngRepeat: category in rstCategories -->
                      <!-- 次分类 -->
                    <div id ='secondType' ng-show="subCategories" class="excavator-filter-subbox" style = "display:none">
                        <!-- ngRepeat: subitem in subCategories --><a
                                class="excavator-filter-item ng-binding ng-scope focus" href="javascript:"
                                ng-repeat="subitem in subCategories"
                                ng-class="{'focus': clickedCategory === subitem.id}"
                                ng-bind="subitem.name" ng-click="changeCategory(subitem)" id = "did"></a>
                      
                        <!-- end ngRepeat: subitem in subCategories -->
                        <!-- end ngRepeat: subitem in subCategories -->
                    </div>
                </div><!-- end ngIf: rstCategories.length --></div>
            <div class="place-rstbox clearfix">
                <div style="height: 100%;"
                     data="filteredRestaurants = (rstStream.restaurants | filter: rstStream.filter | filter: otherFilter | orderBy: [ '-is_opening', rstStream.orderBy || 'index' ])"
                     class="clearfix" id = "goods">
                      <!-- 商家列表 -->
                    @foreach($businesses as $business)
                        @if($business -> star )
                            <a href="{{asset('')}}shop/{{ $business -> id }}" target="_blank" data-bidding=""
                                 data-rst-id="1300459" class="rstblock-closed rstblock">商家暂停营业
                        @else
                            <a href="{{asset('')}}shop/{{ $business -> id }}" target="_blank" data-bidding=""
                                 data-rst-id="1300459" class="rstblock">
                        @endif
                                         
                        <div class="rstblock-logo"><img
                                    src="{{ $business -> img }}"
                                    alt="{{ $business -> username }}"
                                    class="rstblock-logo-icon" height="70" width="70"><span>40 分钟</span>
                        </div>
                        <div class="rstblock-content">
                            <div class="rstblock-title">{{ $business -> username }}</div>
                            <div class="starrating icon-star"><span class="icon-star" style="width: 70%;"></span></div>
                            <span class="rstblock-monthsales">月售</span>
                            <div class="rstblock-cost">20元起送 / 配送费5元</div>
                            <div class="rstblock-activity">
                              <i style="background:#57A9FF;">准</i>
                              <i style="background:#fff;color:#4B9A18;border:1px solid;padding:0;">保</i>
                            </div>
                        </div>
                      </a>
                  @endforeach
                </div>
                <div ng-show="rstStream.status === 'LOADING'" loading="" content="正在载入更多商家..." type="normal"
                     class="loading ng-binding ng-isolate-scope ng-hide"><!-- ngIf: type==='profile' -->
                    <!-- ngIf: type==='normal' --><img ng-if="type==='normal'" class="normal ng-scope"
                                                       src="{{asset('home/home/images/loading.0e7b2e.gif')}}"
                                                       alt="正在加载">
                    <!-- end ngIf: type==='normal' -->正在载入更多商家...
                </div>
                <div class="" id="fetchMoreRst"
                     ng-hide="rstStream.status === 'LOADING' || rstStream.status === 'COMPLETE'">
                    点击加载更多商家...
                </div>
                <div class="place-rstbox-nodata ng-hide"
                     ng-show="rstStream.status === 'COMPLETE' &amp;&amp; !filteredRestaurants.length"><img
                            class="nodata"
                            src="{{asset('home/home/images/515e979f6fd9cc4d82b41a4263e9cpng.png')}}"
                            src="{{asset('home/home/images/icon-restaurant.b3a359.png')}}"

                            alt="找不到商家"
                            width="100">
                    <div class="typo-small">附近没有找到符合条件的商家，换个筛选条件试试吧</div>
                    <input  type = 'hidden' name = 'city' value = '{{ $city }}' class = 'hdcity'>
                    <input  type = 'hidden' name = 'address' value = '{{ $address }}' class = 'hdaddress'>
                </div>
            </div>
        </div>

    </div>

    <script>
//        style="top: -98px;"
        window.onload = function() {

            // 轮播图js开始
            var i = 0;
            var top = 0;
            $("ul[ng-transclude='scrolled']").css('top', '0px');
            $("li[ng-click='setActiveSlide(1)']").css('background', '#f90');
            setInterval(function() {
                i++;
                switch (i) {
                    case 1:
                        $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                        $("li[ng-click='setActiveSlide(2)']").css('background', '#f90');
                        top = -98 * (i);
                        break
                    case 2:
                        $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                        $("li[ng-click='setActiveSlide(3)']").css('background', '#f90');
                        top = -98 * (i);
                        break
                    case 3:
                        $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                        $("li[ng-click='setActiveSlide(1)']").css('background', '#f90');
                        top = 0;
                        i = 0;
                        break
                }
                $("ul[ng-transclude='scrolled']").css('top', top+'px');
            }, 3000);

            $("li[ng-click='setActiveSlide(1)']").on('click', function() {
                $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                $(this).css('background', '#f90');
                $("ul[ng-transclude='scrolled']").css('top', '0px');
                top = 0;
                i = 0;
            });
            $("li[ng-click='setActiveSlide(2)']").on('click', function() {
                $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                $(this).css('background', '#f90');
                $("ul[ng-transclude='scrolled']").css('top', '-98px');
                top = -98;
                i = 1;
            });
            $("li[ng-click='setActiveSlide(3)']").on('click', function() {
                $("li[ng-class='scrolled_pos']").css('background', '#abcdef')
                $(this).css('background', '#f90');
                $("ul[ng-transclude='scrolled']").css('top', '-196px');
                top = -196;
                i = 2;
            });
            // 轮播图js结束
             //搜索商家
            $('.place-search-btn').on('click',function(){
              var keyword = $('#globalsearch').val();
              $.get('/place/show/ajax4',{keyword:keyword},function(data){
               $('#goods').empty();
                $.each(data,function(i){
                var list ="<a href='{{asset('')}}shop/"+data[i]['id']+"' target='_blank' data-bidding='' data-rst-id='1300459' class='rstblock'><div class='rstblock-logo'><img src='"+ data[i]['img']+"' alt='"+ data[i]['username']+"' class='rstblock-logo-icon' height='70' width='70'><span>40 分钟</span></div><div class='rstblock-content'><div class='rstblock-title'>"+data[i]['username']+"</div><div class='starrating icon-star'><span class='icon-star' style='width: 70%;'></span></div><span class='rstblock-monthsales'>月售</span><div class='rstblock-cost'>20元起送 / 配送费5元</div><div class='rstblock-activity'><i style='background:#57A9FF;'>准</i><i style='background:#fff;color:#4B9A18;border:1px solid;padding:0;'>保</i></div></div></a>";
                        // console.log(list);
                $(list).appendTo($('#goods'));
                });
              },'json');
            });
             //二级分类开始隐藏,点击一级分类显示
            $('a[id = "firstType"]').on('click',function(){

                var id = $(this).attr('value');
                var name = $(this).html();
                $.get('/place/show/ajax',{id:id},function(data){
                    $('#did').html('全部'+name);
                    $('#did ~ a').remove();
                    $.each(data,function(i){
                        var name = '<a  id = "makeGoods" value = "'+ data[i]['id'] +'" class="excavator-filter-item ng-binding ng-scope">'+data[i]['name']+'</a>';
                        $(name).appendTo($('#secondType'));
                        $('a[id = "makeGoods"]').css('cursor','pointer');
                        $('#secondType').css('display','block');
                    });
                    
                },'json');
            });
            // 点击二级分类，遍历商家的ajax
            var cateid = '';
            $('a[id ="makeGoods"]').live('click',function(){
                $('a[id ="makeGoods"]').removeClass()
                $('a[id ="makeGoods"]').addClass('excavator-filter-item ng-binding ng-scope')
                $(this).addClass('excavator-filter-item ng-binding ng-scope focus')
              cateid = $(this).attr('value');
              $.get('/place/show/ajax2',{cateid:cateid},function(data){
                    $('#goods').empty();
                    $.each(data,function(i){
                        var list ="<a href='{{asset('')}}shop/"+data[i]['id']+"' target='_blank' data-bidding='' data-rst-id='1300459' class='rstblock'><div class='rstblock-logo'><img src='"+ data[i]['img']+"' alt='"+ data[i]['username']+"' class='rstblock-logo-icon' height='70' width='70'><span>40 分钟</span></div><div class='rstblock-content'><div class='rstblock-title'>"+data[i]['username']+"</div><div class='starrating icon-star'><span class='icon-star' style='width: 70%;'></span></div><span class='rstblock-monthsales'>月售</span><div class='rstblock-cost'>20元起送 / 配送费5元</div><div class='rstblock-activity'><i style='background:#57A9FF;'>准</i><i style='background:#fff;color:#4B9A18;border:1px solid;padding:0;'>保</i></div></div></a>";
                        // console.log(list);
                        $(list).appendTo($('#goods'));
                    });
              },'json');
            });
            //加载更多商家
            var p =2;
            var address = $('.hdaddress').val();
            var city = $('.hdcity').val();
            $('#fetchMoreRst').on('click',function(){
                $.get('/place/show/ajax3',{cateid:cateid,p:p,address:address,city:city},function(data){

                    $.each(data,function(i){
                        var more ="<a href='{{asset('')}}shop/"+data[i]['id']+"' target='_blank' data-bidding='' data-rst-id='1300459' class='rstblock'><div class='rstblock-logo'><img src='"+ data[i]['img']+"' alt='"+ data[i]['username']+"' class='rstblock-logo-icon' height='70' width='70'><span>40 分钟</span></div><div class='rstblock-content'><div class='rstblock-title'>"+data[i]['username']+"</div><div class='starrating icon-star'><span class='icon-star' style='width: 70%;'></span></div><span class='rstblock-monthsales'>月售</span><div class='rstblock-cost'>20元起送 / 配送费5元</div><div class='rstblock-activity'><i style='background: rgb(231, 89, 89) none repeat scroll 0% 0%;'>新</i></div></div></a>";                        
                        $('#goods > a :last').after($(more));
                    });
                    p++;
              },'json');
            });

        }


        
    </script>

         
    
@endsection
